import { BblCase } from "../entity/case.entity";
import { AttachDto } from "./att.dto";

export class CaseCreateDto {
  /**
   * 案例主标题
   */
  caseMainTitle: string;
  /**
   * 案例副标题
   */
  caseSubTitle: string;
  /**
   * 封面图片
   */
  caseCoverAttId: string;
  /**
   * 案例主图
   */
  caseMainAttIds: string[];
  /**
   * 案例描述
   */
  caseText: string;
}

export class CaseUpdateDto {
  /**
   * 案例主标题
   */
  caseMainTitle: string;
  /**
   * 案例副标题
   */
  caseSubTitle: string;
  /**
   * 封面图片
   */
  caseCoverAttId: string;
  /**
   * 案例主图
   */
  caseMainAttIds: string[];
  /**
   * 案例描述
   */
  caseText: string;
}

export class CasePageQueryDto {
  /**
   * 案例主标题
   */
  caseMainTitle: string;
  /**
   * 案例副标题
   */
  caseSubTitle: string;
  /**
   * 当前页
   */
  current: number;
  /**
   * 每页条数
   */
  pageSize: number;
}

export class CaseDto {
  constructor(bcase: BblCase) {
    this.caseId = bcase.caseId;
    this.caseMainTitle = bcase.caseMainTitle;
    this.caseSubTitle = bcase.caseSubTitle;
    this.caseText = bcase.caseText;
    this.createAt = bcase.createAt.valueOf();
    this.caseCoverImg = new AttachDto(bcase.caseCoverImg);
    if (bcase.caseMainImgs) {
      this.caseMainImgs = bcase.caseMainImgs.map((d) => new AttachDto(d));
    }
  }
  caseId: string;
  caseMainTitle: string;
  caseSubTitle: string;
  caseCoverImg: AttachDto;
  caseMainImgs: AttachDto[] = [];
  caseText: string;
  createAt: number;
}
